# import requests
# import re
# import json
# from bs4 import BeautifulSoup
# import csv
# from lxml import etree
# if __name__== "__main__":
#     headers={
#         'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 Edg/124.0.0.0'  
#     }

#     url='https://cd.58.com/ershoufang/'

#     resp=requests.get(url,headers=headers)
#     xp_tx=etree.HTML(resp.text)
#     with open ('.\爬取的文档\\58二手房.text','w',encoding='utf-8') as fp :
#         abbcc=xp_tx.xpath('//div[@class="property-content-detail"]/div[@class="property-content-title"]//h3/@title')
#         print(abbcc)
#         for i in abbcc:
#             print(i,file=fp)
#     print('ok')




import requests
import re
import json
from bs4 import BeautifulSoup
import csv
from lxml import etree
if __name__== "__main__":
    headers={
        'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 Edg/124.0.0.0'  
    }

    url='https://sy.zu.anjuke.com/map/ajax/pclist/Api_get_house_list?refer_url=&p=1&maxp=99&room_num=0&price_id=0&rent_type=0&price_min=0&price_max=0&lx_id=&tag_id=&orient_id=&order_id=0&lat=18.306554_18.323508&lng=109.511939_109.572987&zoom=16&community_id=100590915&ib=1&et=c1189b&bst=pzm134'

    resp=requests.get(url,headers=headers)
    # with open ('.\爬取的文档\\58二手房_price.text','w',encoding='utf-8') as fp :
    #     s=json.dumps(resp.json(),ensure_ascii=False,indent=4)
    #     print(s,file=fp)
    appppp=[]
    with open ('.\爬取的文档\\58二手房_price_2.text','w',encoding='utf-8') as fp :
        ask=resp.json()
        ask=ask["val"]
        ask=ask["props"]
        for i in ask :
            appppp.append(i["price"])
        appppp.sort()
        for i in appppp:
            print('价格：',i,file=fp)
    print('ok')